package com.eedi.framework.mail.dal.mapper;

import com.eedi.framework.common.pojo.PageResult;
import com.eedi.framework.mail.controller.sys.vo.log.MailLogPageReq;
import com.eedi.framework.mybatis.core.mapper.BaseMapperX;
import com.eedi.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.eedi.framework.mail.dal.dataobject.SysMailLogDO;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface SysMailLogMapper extends BaseMapperX<SysMailLogDO> {

    default PageResult<SysMailLogDO> selectPage(MailLogPageReq reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SysMailLogDO>()
                .eqIfPresent(SysMailLogDO::getUserId, reqVO.getUserId())
                .eqIfPresent(SysMailLogDO::getUserType, reqVO.getUserType())
                .likeIfPresent(SysMailLogDO::getToMail, reqVO.getToMail())
                .eqIfPresent(SysMailLogDO::getSysMailAccountId, reqVO.getAccountId())
                .eqIfPresent(SysMailLogDO::getMailTemplateId, reqVO.getTemplateId())
                .eqIfPresent(SysMailLogDO::getSendStatus, reqVO.getSendStatus())
                .betweenIfPresent(SysMailLogDO::getSendTime, reqVO.getSendTime())
                .orderByDesc(SysMailLogDO::getId));
    }

}
